using System;
using Genko.Model.Resources;

namespace Genko.Model.Collections
{
	internal class DefaultMemberList : MutableMemberList
	{
		private int threshold = 10;

		internal DefaultMemberList()
		{
			try {
				this.threshold = Int32.Parse(GenkoModelRes.DefaultMemberListThreshold);
			} catch {
			}
		}

		public virtual int Threshold
		{
			get { return this.threshold; }
			set { this.threshold = value; }
		}

		protected override MemberList CreateDefaultMemberList()
		{
			return new LinkedMemberList();
		}

		protected override bool MutateIfNecessary()
		{
			if (this.Count > this.Threshold) {
				MemberList memberList = new LinkedMemberList(); //new HashMemberList();
				memberList.Add(memberList);
				this.MemberList = memberList;
				return true;
			}
			return false;
		}
	}
}
